var isIdChecked = false;

var fstNum = "";
var midNum = "";
var lastNum = "";

function checkJoinInput() {
	var msg = document.getElementById("message");
	msg.style.color = "red";
	
	var firstNum = document.getElementById("pNum").value;
	var midNum = document.getElementById("midNum").value;
	var lastNum = document.getElementById("lastNum").value;
	var pNum = firstNum + midNum + lastNum;
	document.getElementById("pNum").value = pNum;
	
	if(document.getElementById("userId").value == "") {
		msg.innerHTML = "아이디를 입력하세요";
		return;
	}
	if(isIdChecked == false) {
		msg.innerHTML = "아이디 중복체크를 해주세요";
		return;
	}
	if(document.getElementById("password").value == "") {
		msg.innerHTML = "비밀번호를 입력하세요";
		return;
	}
	if(document.getElementById("password_confirm").value == "") {
		msg.innerHTML = "비밀번호 확인을 위해 한번 더 입력해 주세요";
		return;
	}
	if(document.getElementById("password").value !== document.getElementById("password_confirm").value) {
		msg.innerHTML = "비밀번호가 일치하지 않습니다";
		return;
	}
	if(document.getElementById("userName").value == "") {
		msg.innerHTML = "이름을 입력해 주세요";
		return;
	}
	if(document.getElementById("email").value == "") {
		msg.innerHTML = "E-mail을 입력해 주세요";
		return;
	}
	if(isNaN(pNum)) {
		msg.innerHTML = "휴대폰 번호는 숫자로 입력하세요";
		return;
	}
	if(document.getElementById("pNum").value == "" || document.getElementById("pNum").value.length > 11) {
		msg.innerHTML = "휴대폰 번호를 입력해 주세요";
		return;
	}
	msg.style.color = "black";
	msg.innerHTML = "고객님 정보를 서버로 보내는 중입니다.";
//	document.joinForm.submit();
	document.getElementById("joinForm").submit();
}
function checkIdDuplication() {
	var IdCheckWindow = window.open("member_idchk.jsp", "","width=300, height=200" );
	IdCheckWindow.userId = document.getElementById("userId").value;
	//document.getElementById("isIdChecked").value = "checked";
}
function changeIdDupState() {
	this.isIdChecked = false;
}

function selectLang(which, langId, langBtn, langid) {
	var langName = which.innerHTML;
	langBtn.innerHTML = langName + "<span class='caret'></span>";
	langid.value = langId;
	return;
}
function changeNum(which) {
	var firstNum = which.innerHTML;
	document.getElementById("pNum").value = firstNum;
	document.getElementById("fstPNum").innerHTML = firstNum;
}

function phoneNum(which) {
	var pNum = which.value;
	if(which.id == "midNum") {
		if(pNum.length > 4) {
			document.getElementById("lastNum").focus();
			pNum = pNum.substring(0,4);
			document.getElementById("midNum").value = pNum;
		}
	}
	else if(which.id == "lastNum") {
		if(pNum.length > 4) {
			document.getElementById("univ").focus();
			pNum = pNum.substring(0,4);
			document.getElementById("lastNum").value = pNum;
		}
	}
	//alert(midNum);
}
